package com.pug.test.rest;

import com.alibaba.fastjson.JSON;
import com.pug.test.dto.BuyReqDTO;
import com.pug.test.dto.BuyRespDTO;
import com.pug.test.service.IBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xq.pug.common.result.R;

/**
 * @program: xq_pug_alibabacloud_parent
 * @description:
 * @author: Mr.Ren
 * @create: 2023-06-03 15:40
 **/
@RestController
@RequestMapping("/business")
@Slf4j
public class BusinessController {

    @Autowired
    private IBusinessService businessService;

    @PostMapping("/buy")
    public R<BuyRespDTO> order(@RequestBody BuyReqDTO dto){
        log.info("业务方法，请求参数：{}", JSON.toJSONString(dto));
        BuyRespDTO resp = businessService.buy(dto);
        log.info("业务方法，响应参数：{}", JSON.toJSONString(resp));
        return R.ofSuccess(resp);
    }
}
